@extends('layouts.default')
@section('content')
    <div class="container">
        <div class="row row-display row-centered">
            <div class="col-md-6 col-centered">
                <!-- /.box-header -->
                <!-- form start -->
                <form role="form" action="{{route('permissions.store')}}" method="post">
                    {{ csrf_field() }}
                    <div class="box-body">
                        <div class="form-group">
                            <label>所属菜单</label>
                            <select class="form-control"  name="pid">
                                <option value="0"> / </option>
                                @if($permissionstree)
                                    @foreach($permissionstree as $menu)
                                        <option value="{{ $menu->id }}">{{ $menu->display_name }}</option>
                                    @endforeach
                                @endif
                            </select>
                        </div>
                        <div class="form-group">
                            <label>菜单名</label>
                            <input type="text" class="form-control" name="display_name" value="{{old('display_name')}}">
                        </div>
                        <div class="form-group">
                            <label>菜单路由</label>
                            <select class="form-control"  name="name" data-live-search="true">
                                <option value="">请选择</option>
                                @if($routename)
                                    @foreach($routename as $name)
                                        <option value="{{ $name }}">{{ $name }}</option>
                                    @endforeach
                                @endif
                            </select>
                        </div>
                        <div class="form-group">
                            <label>菜单图标</label>
                            <input type="text" class="form-control" name="icon" value="{{old('icon')}}" placeholder="默认:fa fa-circle-o">
                            <span class="span-text"><a href="http://www.thinkcmf.com/font/icons" target="_blank">选择图标</a></span>
                        </div>
                        <div class="form-group">
                            <label>描述</label>
                            <textarea class="form-control" rows="3" name="description">{{old('description')}}</textarea>
                        </div>
                        <div class="form-group">
                            <label>是否显示</label>
                            <div class="switch switch-large">
                                <input type="checkbox" checked/>
                                <input type="hidden" name="is_show" value="1"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label>排序</label>
                            <input type="number" class="form-control" name="sort" value="50" max="100" min="0">
                            <span class="span-text">数字越小,显示越靠前</span>
                        </div>
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer">
                        <button type="submit" class="btn btn-primary pull-left">保存</button>
                        <a href="{{ url()->previous() }}" class="btn btn-primary pull-right">返回</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script>
        $('input[type="checkbox"]').bootstrapSwitch({
            onColor: "success",
            offColor: "danger",
            size: "small",
            onSwitchChange:function(event,state){
                if(state==true){
                    $('input[name="is_show"]').val(1)
                }else{
                    $('input[name="is_show"]').val(0)
                }
            }
        });
    </script>
@stop